home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / ms_dos / dmove86 / sectbl.c < prev   
Text File  |  1993-11-30  |  1KB  |  66 lines

  1. /*
  2.  
  3. sectbl.c -- control()の下請け;セクタテーブルの処理
  4.  
  5. */
  6.  
  7. #include<stdio.h>
  8. #include<dos.h>
  9. #include<malloc.h>
  10. #include"dmove86.h"
  11.  
  12. void        freesectbl(sectbl)
  13. struct SECTBL    *sectbl;
  14. {
  15.     struct SECTBL    *tblfree;
  16.  
  17.     while (sectbl != NULL)
  18.     {
  19.         tblfree = sectbl;
  20.         farfree(tblfree->buf);
  21.         sectbl = tblfree->next;
  22.         free(tblfree);
  23.     }
  24. }
  25.  
  26. extern    struct DPB    Dpb;
  27. extern    int        Drive;
  28.  
  29. void        writedir(sectbl,dirtbl,dirnum)
  30. struct SECTBL    *sectbl;
  31. struct DIRENTRY    far **dirtbl;
  32. unsigned int    dirnum;
  33. {
  34.     struct DIRENTRY    far *buftop =
  35.             (struct DIRENTRY far *)farmalloc(Dpb.seclen);
  36.     struct DIRENTRY    far *buf;
  37.     int        i;
  38.     unsigned    n;
  39.  
  40.     if    (buftop == NULL)
  41.     {
  42.         dm_errmes("メモリ不足で書き込めません");
  43.         goto ENDWRITING;
  44.     }
  45.  
  46.     while    (sectbl != NULL)
  47.     {
  48.         buf = buftop;
  49.  
  50.         for    (i=0 ; i<DIRSEC ; i++)
  51.             *(buf++) = **(dirtbl++);    /* 構造体のコピー */
  52.  
  53.         if    ((n=wrabssec(buftop, sectbl->num, Drive)) & 0x100)
  54.         {
  55.             dm_errmes("書き込みエラーです");
  56.             goto ENDWRITING;
  57.         }
  58.  
  59.         sectbl = sectbl->next;
  60.  
  61.     }
  62. ENDWRITING:;
  63.     farfree(buftop);
  64. }
  65.  
  66.